/*
 * PopupCanvassWidget.hpp
 *
 *  Created on: Jul 16, 2012
 *      Author: guillou
 */

#ifndef POPUPCANVASSWIDGET_HPP_
#define POPUPCANVASSWIDGET_HPP_

#include <QTimer>
#include <PopupLibTypes.hpp>
#include <ui_canvasswidget.h>

class PopupChoiceWidget;
class PopupCanvassResult;

class PopupCanvassWidget : public QWidget, private Ui_CanvassWidget
{
  Q_OBJECT

public:
  PopupCanvassWidget(QWidget *p_parent,
                     const Popup::Canvass & p_canvass);
  virtual ~PopupCanvassWidget() {}

  void processVote(const Popup::Vote & p_vote);
  void onChoiceToggled(PopupChoiceWidget *p_choice, bool status);

private slots:
  void slot_vote();
  void slot_updateTimeLeft();

signals:
  void signal_sendVote(Popup::Vote *p_vote);

private:
  void showResults();

  Popup::Canvass canvass;
  std::set<PopupChoiceWidget*> selectedChoices;
  std::map<unsigned short, PopupCanvassResult*> resultWidgets;
  QTimer _timer;
  int m_nbVotesCollected;
};

#endif /* POPUPCANVASSWIDGET_HPP_ */
